package com.newcoder.controller;


import com.newcoder.service.impl.FollowServiceImpl;
import com.newcoder.util.CommunityConstant;
import com.newcoder.util.ResponseWrapper;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/follow")
public class FollowController implements CommunityConstant {

    @Autowired
    private FollowServiceImpl followService;

    @ApiOperation("关注")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId",value = "userId"),
            @ApiImplicitParam(name = "entityType",value = "entityType"),
            @ApiImplicitParam(name = "entityId",value = "entityId"),
    })
    @GetMapping("/follow")
    public ResponseWrapper follow(Integer userId, Integer entityType, Integer entityId){
        ResponseWrapper wrapper = followService.follow(userId, entityType, entityId);
        return wrapper;
    }

    @ApiOperation("取消关注")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId",value = "userId"),
            @ApiImplicitParam(name = "entityType",value = "entityType"),
            @ApiImplicitParam(name = "entityId",value = "entityId"),
    })
    @GetMapping("/unfollow")
    public ResponseWrapper unfollow(Integer userId, Integer entityType, Integer entityId){
        ResponseWrapper wrapper = followService.unfollow(userId, entityType, entityId);
        return wrapper;
    }

    @ApiOperation("查询我关注的人")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId",value = "userId"),
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",defaultValue = "1"),
            @ApiImplicitParam(name = "pageSize",value = "每页展示的数据条数",defaultValue = "10"),
    })
    @GetMapping("/selectFolloweesPage")
    public ResponseWrapper selectFolloweesPage(Integer userId, Integer currentPage, Integer pageSize){
        ResponseWrapper wrapper = followService.selectFolloweesPage(userId, currentPage, pageSize);
        return wrapper;
    }

    @ApiOperation("查询关注我的人（查询粉丝）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId",value = "userId"),
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",defaultValue = "1"),
            @ApiImplicitParam(name = "pageSize",value = "每页展示的数据条数",defaultValue = "10"),
    })
    @GetMapping("/selectFollowersPage")
    public ResponseWrapper selectFollowersPage(Integer userId, Integer currentPage, Integer pageSize){
        ResponseWrapper wrapper = followService.selectFollowersPage(userId, currentPage, pageSize);
        return wrapper;
    }
}
